<?php
 interface SchoolReport{
     public function report();
     public function sign($name);
 }


class FouthGradeSchoolReport implements SchoolReport{
    public function report(){
        echo "尊敬的XXX家长:</br>";
        echo " 语文 62 数学65 体育 98 自然 63</br>";
        echo "  家长签名：";
    }

    public function sign($name){
        echo "家长签名为：$name","</br>";
    }
}

class Decorator implements SchoolReport{
    private $schoolReort;

    public function __construct($schoolReport){
        $this->schoolReort=$schoolReport;
    }

    public function report(){
        $this->schoolReort->report();
    }

    public function sign($name){
        $this->schoolReort->sign($name);
    }
}


class HighScoreDecorator extends Decorator{
    public function __construct($schoolReport){
        parent::__construct($schoolReport);
    }

    public function reportHighScore(){
        echo "这次考试语文最高是75,数学是78,自然是80</br>";
    }
    public function report(){
        $this->reportHighScore();
        parent::report();
    }
}

class SortDecorator extends Decorator{
    public function __construct($schoolReport){
        parent::__construct($schoolReport);
    }

    public function reportSort(){
        echo "我是排名第38名...</br>";
    }

    public function report(){
        parent::report();
        $this->reportSort();
    }
}


//父亲查看成绩单位
echo "<meta charset='UTF-8'>";
$sr=new FouthGradeSchoolReport();
$sr=new HighScoreDecorator($sr);
$sr=new SortDecorator($sr);
$sr->report();
$sr->sign("老三");


?>